#ifndef _CFG_H
#define _CFG_H

#include <QXmlDefaultHandler>

class Cfg : public QXmlDefaultHandler
{
	public:
		struct {
			QString name;
			QString author;
			QString mail;
			QString www;
			QString desc;
		} m_info;
		struct {
			bool isValid;
			QPoint pt;
			QPixmap pix;
		} m_bottom;
		struct {
			bool isValid;
			QRect rect;
			QPixmap no_cover_pix;
		} m_cover;
		struct {
			bool isValid;
			QPoint pt;
			QPixmap pix;
		} m_top;
		struct {
			bool isValid;
			QRect rect;
			struct {
				int angle;
				QPoint pt;
			} rotation;
		} m_merged;
		int m_width, m_height;
		struct {
			QString text;
			QRect rect;
		} m_text;

		void clear();
		void load(const QString &path);

		bool characters(const QString &ch);
		bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
		bool startDocument();
		bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts);

	private:
		QString m_path;
		int m_id;

		int findChildElementId(const QString &localName);
		int findParentElementId();
};

#endif // _CFG_H
